package com.substation.ui.utils;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.bumptech.glide.Glide;
import com.substation.R;
import com.wenld.wenldbanner.DefaultPageIndicator;
import com.wenld.wenldbanner.WenldBanner;
import com.wenld.wenldbanner.helper.Holder;
import com.wenld.wenldbanner.helper.ViewHolder;

import java.util.List;


/**
 * Created by admin on 2017/12/8.
 */

public class BannerUtils {

    public static void setBannerString(Context context, final List<String> datas, WenldBanner wenldBanner){
        DefaultPageIndicator defaultPageIndicator=new DefaultPageIndicator(context);
        defaultPageIndicator.setPageIndicator(new int[]{R.mipmap.ic_page_indicator,R.mipmap.ic_page_indicator_focused});
        wenldBanner.setPages(new Holder<String>() {
            @Override
            public ViewHolder createView(Context context, ViewGroup viewGroup, int i, int i1) {
                return ViewHolder.createViewHolder(context, viewGroup,  R.layout.view_banner, getViewType(i));
            }

            @Override
            public void UpdateUI(final Context context, ViewHolder viewHolder, final int i, String o) {
                Glide.with(context).load(o).into((ImageView) viewHolder.getView(R.id.imageView));
                viewHolder.setOnClickListener(R.id.imageView, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                });
            }

            @Override
            public int getViewType(int i) {
                return i;
            }
        },datas);
        wenldBanner.setPageIndicatorListener(defaultPageIndicator)  //设置指示器监听
                .setIndicatorView(defaultPageIndicator)  //设置指示器VIew
                .setPageIndicatorAlign(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.CENTER_HORIZONTAL);    //设置指示器位置
    }
}
